Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package Gaia #8

Merged
merged 7 commits into from
Aug 17, 2021
Merged

Conversation

JonathanLorimer
Copy link
Collaborator

No description provided.

@JonathanLorimer JonathanLorimer marked this pull request as draft August 9, 2021 00:57
@JonathanLorimer
Copy link
Collaborator Author

This is effectively ready for review, but depends on some changes in #5 so I will leave in draft until that is merged and I can rebase!

@JonathanLorimer
Copy link
Collaborator Author

Closes #13

@JonathanLorimer JonathanLorimer marked this pull request as ready for review August 16, 2021 14:16
syncGoModulesInputs = with builtins; concatStringsSep " "
(attrValues (builtins.mapAttrs (name: value: "${name}${value}") goProjectSrcs));
syncGoModulesScript = pkgs.writeShellScriptBin "syncGoModules" ''
echo "${syncGoModulesInputs}" | ./syncGoModules.hs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of syncing the narHash?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so this is a bit complicated, but gomod2nix does not provide any tooling for generating dependency information dynamically from within nix. So we need to clone the go repo, call gomod2nix from the command line, and then use the generated go-modules.toml. So I wrote a script that does that for us, this way if we add more go repos or have to update the dependencies we can update our gomod2nix file as well. However, this would be pretty easy to forget to do, so when my script generates the go-modules.toml, it also spits out the narHash from the flake.lock file, this allows us to keep track of when we last synced the go modules.

Once I am done packaging all the software I want to add a flake check that will go into each go package's subdirectory and check to see if the narHash matches the one in flake.lock this way we can get a CI failure if someone updates the flake input but forgets to run syncGoModules

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. I didn't look too much into it, but I guess this is similar to the hashes generated by Haskell.nix which needs to be checked in to source control. I think a potential issue is that users may encounter hash mismatch if they update the source code for Gaia to a different version and didn't execute the sync script.

This should work for now until we find a better solution.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a potential issue is that users may encounter hash mismatch if they update the source code for Gaia to a different version and didn't execute the sync script.

This is absolutely correct. That's why I want to either set up an assertion in the flake as a pre-commit hook that will fail if the hash is different, or setup a check that will fail in CI if the hashes are different. I will probably do both actually

@soareschen soareschen merged commit a6191e8 into informalsystems:master Aug 17, 2021
@JonathanLorimer JonathanLorimer mentioned this pull request Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants